// 模拟后端动态生成路由
import { defineFakeRoute } from "vite-plugin-fake-server/client";

/**
 * roles：页面级别权限，这里模拟二种 "admin"、"common"
 * admin：管理员角色
 * common：普通角色
 */
const controlRouter = {
  path: "/control",
  meta: {
    title: "主控面板",
    icon: "ep:menu",
    rank: 5
  },
  children: [
    {
      path: "/control/index",
      name: "Control",
      component: "control/index",
      meta: {
        title: "主控面板",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const userRouter = {
  path: "/user",
  meta: {
    title: "人员管理",
    icon: "ep:user",
    rank: 6
  },
  children: [
    {
      path: "/user/index",
      name: "User",
      component: "user/index",
      meta: {
        title: "人员管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const chartsRouter = {
  path: "/charts",
  meta: {
    title: "图表",
    icon: "ep:pie-chart",
    rank: 998
  },
  children: [
    {
      path: "/charts/index",
      name: "Charts",
      component: "charts/index",
      meta: {
        title: "图表",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const settingRouter = {
  path: "/setting",
  meta: {
    title: "系统设置",
    icon: "Setting",
    rank: 1000
  },
  children: [
    {
      path: "/setting/index",
      name: "Setting",
      component: "setting/index",
      meta: {
        title: "系统设置",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const changeMajorRouter = {
  path: "/changeMajor",
  meta: {
    title: "转专业",
    icon: "ep:stamp",
    rank: 6
  },
  children: [
    {
      path: "/changeMajor/index",
      name: "ChangeMajor",
      component: "changeMajor/index",
      meta: {
        title: "转专业",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const changeDepartmentRouter = {
  path: "/changeDepartment",
  meta: {
    title: "转部门",
    icon: "ep:suitcase-line",
    rank: 6
  },
  children: [
    {
      path: "/changeDepartment/index",
      name: "ChangeDepartment",
      component: "changeDepartment/index",
      meta: {
        title: "转部门",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const institutionRouter = {
  path: "/institution",
  meta: {
    title: "机构管理",
    icon: "ep:school",
    rank: 6
  },
  children: [
    {
      path: "/institution/index",
      name: "Institution",
      component: "institution/index",
      meta: {
        title: "机构管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const academyRouter = {
  path: "/academy",
  meta: {
    title: "学院管理",
    icon: "ep:office-building",
    rank: 6
  },
  children: [
    {
      path: "/academy/index",
      name: "Academy",
      component: "academy/index",
      meta: {
        title: "学院管理树",
        roles: ["默认管理员", "测试管理员"]
      }
    },
    {
      path: "/academy2/index",
      name: "Academy2",
      component: "academy2/index",
      meta: {
        title: "学院管理表",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const loanRouter = {
  path: "/loan",
  meta: {
    title: "部门借调",
    icon: "ep:suitcase",
    rank: 6
  },
  children: [
    {
      path: "/loan/index",
      name: "Loan",
      component: "loan/index",
      meta: {
        title: "部门借调",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const controlAuthorityRouter = {
  path: "/controlAuthority",
  meta: {
    title: "权限面板",
    icon: "hugeicons:access",
    rank: 9
  },
  children: [
    {
      path: "/controlAuthority/index",
      name: "ControlAuthority",
      component: "controlAuthority/index",
      meta: {
        title: "权限面板",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const controlAllowRouter = {
  path: "/controlAllow",
  meta: {
    title: "白名单管理",
    icon: "ep:finished",
    rank: 7
  },
  children: [
    {
      path: "/controlAllow/index",
      name: "ControlAllow",
      component: "controlAllow/index",
      meta: {
        title: "白名单管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const controlAdminerRouter = {
  path: "/controlAdminer",
  meta: {
    title: "管理员管理",
    icon: "ep:coordinate",
    rank: 8
  },
  children: [
    {
      path: "/controlAdminer/index",
      name: "ControlAdminer",
      component: "controlAdminer/index",
      meta: {
        title: "管理员管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const controlRoleRouter = {
  path: "/controlRole",
  meta: {
    title: "角色管理",
    icon: "ep:user-filled",
    rank: 8
  },
  children: [
    {
      path: "/controlRole/index",
      name: "controlRole",
      component: "controlRole/index",
      meta: {
        title: "角色管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const controlTeamRouter = {
  path: "/controlTeam",
  meta: {
    title: "公共账号管理",
    icon: "ep:connection",
    rank: 8
  },
  children: [
    {
      path: "/controlTeam/index",
      name: "ControlTeam",
      component: "controlTeam/index",
      meta: {
        title: "公共账号管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const teamRouter = {
  path: "/team",
  meta: {
    title: "部门公共账号",
    icon: "ep:paperclip",
    rank: 8
  },
  children: [
    {
      path: "/team/index",
      name: "Team",
      component: "team/index",
      meta: {
        title: "部门公共账号",
        roles: ["默认管理员", "测试管理员"]
      }
    },
    {
      path: "/controlTeam/index",
      name: "ControlTeam",
      component: "controlTeam/index",
      meta: {
        title: "公共账号管理",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const routerConfigRouter = {
  path: "/routerConfig",
  meta: {
    title: "路由配置",
    icon: "ep:guide",
    rank: 9
  },
  children: [
    {
      path: "/routerConfig/index",
      name: "RouterConfig",
      component: "routerConfig/index",
      meta: {
        title: "路由配置",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const tableConfigRouter = {
  path: "/table",
  meta: {
    title: "表格结构管理",
    icon: "ep:document-add",
    rank: 9
  },
  children: [
    {
      path: "/tableConfig/index",
      name: "tableConfig",
      component: "tableConfig/index",
      meta: {
        title: "表格结构配置",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const logRouter = {
  path: "/log",
  meta: {
    title: "日志管理",
    icon: "lucide:file-cog",
    rank: 10
  },
  children: [
    {
      path: "/loginLog",
      name: "LoginLog",
      component: "loginLog/index",
      meta: {
        title: "登录日志",
        roles: ["默认管理员", "测试管理员"]
      }
    },
    {
      path: "/operationLog",
      name: "OperationLog",
      component: "operationLog/index",
      meta: {
        title: "操作日志",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const multipleIdntitiesRouter = {
  path: "/multipleIdntities",
  meta: {
    title: "多身份",
    icon: "ep:avatar",
    rank: 8
  },
  children: [
    {
      path: "/multipleIdntities/index",
      name: "MultipleIdntities",
      component: "multipleIdntities/index",
      meta: {
        title: "多身份",
        roles: ["默认管理员", "测试管理员"]
      }
    }
  ]
};

const permissionRouter = {
  path: "/permission",
  meta: {
    title: "权限管理",
    icon: "ep:lollipop",
    rank: 99
  },
  children: [
    {
      path: "/permission/page/index",
      name: "PermissionPage",
      meta: {
        title: "页面权限",
        roles: ["默认管理员", "测试管理员"]
      }
    },
    {
      path: "/permission/button",
      meta: {
        title: "按钮权限",
        roles: ["默认管理员", "测试管理员"]
      },
      children: [
        {
          path: "/permission/button/router",
          component: "permission/button/index",
          name: "PermissionButtonRouter",
          meta: {
            title: "路由返回按钮权限",
            auths: [
              "permission:btn:add",
              "permission:btn:edit",
              "permission:btn:delete"
            ]
          }
        },
        {
          path: "/permission/button/login",
          component: "permission/button/perms",
          name: "PermissionButtonLogin",
          meta: {
            title: "登录接口返回按钮权限"
          }
        }
      ]
    }
  ]
};

export default defineFakeRoute([
  {
    url: "/get-async-routes",
    method: "get",
    response: () => {
      return {
        success: true,
        data: [
          userRouter,
          academyRouter,
          changeMajorRouter,
          changeDepartmentRouter,
          institutionRouter,
          settingRouter,
          teamRouter,
          loanRouter,
          chartsRouter,
          multipleIdntitiesRouter,
          controlTeamRouter,
          controlRouter,
          controlRoleRouter,
          controlAllowRouter,
          controlAdminerRouter,
          routerConfigRouter,
          controlAuthorityRouter,
          tableConfigRouter,
          logRouter,
          permissionRouter
        ]
      };
    }
  }
]);
